package reflect;

import java.util.ArrayList;
import java.util.Scanner;

public class ReflectDemo2 {
    public static void main(String[] args) throws ClassNotFoundException, InstantiationException, IllegalAccessException {
        ArrayList list = new ArrayList();
        System.out.println(list);

        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入要实例化的类的名字:");
        String className = scanner.next();
        Class cls = Class.forName(className);

        Object obj = cls.newInstance();
        System.out.println(obj);
    }
}
